package com.mingqijia.gassafety.webserver.utils;

import com.alibaba.fastjson.JSONObject;
import com.mingqijia.gassafety.webserver.request.cmp.notify.DataReportRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class ReportLogUtil {
    private static Logger reportLog = LoggerFactory.getLogger("com.mingqijia.gassafety.webserver.utils.ReportLogUtil");

    private static Format format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    /**
     * 上报日志
     * @param uri
     * @param request
     */
    public static void reportLog(String uri, DataReportRequest request){
        Map<String, Object> logData = new HashMap<>();
        logData.put("uri",uri);
        logData.put("data",request);
        logData.put("time",format.format(new Date()));
        reportLog.info(JSONObject.toJSONString(logData));
    }
}
